package com.softmaker.repository;

import com.softmaker.entity.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface UserInfoRepository extends JpaRepository<UserInfo, String> {
    public UserInfo findUserInfoByUserName(String userName);
    @Modifying
    @Query(value="delete from user_info e where e.user_name = ?1",nativeQuery = true)
    void deleteUserInfoByUserName(String userName);
    @Modifying
    @Query(value ="update user_info e set e.password=?1 where e.user_name=?2" ,nativeQuery = true)
    void updatePasswordByUserName(String password,String studentName);
    @Query(value = "select * from user_info e where e.user_name = ?1",nativeQuery = true)
    UserInfo findByUserName(String studentName);
    @Query(value = "select d.video_name from user_info e  join usvi_center q on e.user_id = q.user_id join video d on q.video_id = d.video_id where e.user_id = ?1",nativeQuery = true)
    List<String> getVideoNameByUserId(String userId);
}
